home *** CD-ROM | disk | FTP | other *** search
File List | 1983-11-17 | 13.1 KB | 279 lines |
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-1
-
-
-
- page 55,132
- ;------------------------------------------------------------------------------
- ;PASSWORD.ASM (creates PWORD.SYS, device driver)
- ;
- ;DOS 2.00 Device driver forces user to enter password on booting up
- ;and disables Ctrl-Break.
- ;
- ;After assembly: link PASSWORD (ignore "no STACK" error)
- ; exec2bin PASSWORD PASSWORD.SYS
- ; place DEVICE=PASSWORD.SYS in CONFIG.SYS file
- ; reboot system with Ctrl-Alt-Del
- ; answer prompt with: PassWord <enter>
-
- 0000 dev_seg segment
- 0000 pword_device proc far
- assume cs:dev_seg,ds:dev_seg,es:dev_seg
-
- ;-------------------------------
- ;The following lines are the device header, which must exist for
- ;every device. This file has only one device, and it works with
- ;character I/O. It doesn't actually handle any I/O services,
- ;but it's easier to create a character device.
-
- 0000 pword_dev_header: ;label for the start of the device driver
-
- 0000 FF FF FF FF next_dev_ptr dd -1 ;only 1 device is defined in this file
- 0004 8000 dev_attribute dw 8000h ;character device (simpler that way)
- 0006 0070 R strategy_ptr dw strategy ;the installation proc
- 0008 007B R interrupt_ptr dw interrupt ;the proc that handles all service requests
- 000A 50 41 53 53 57 4F device_name db 'PASSWORD' ;8-byte string of device name
- 52 44
-
- ;--- This is the stroage area for the password --
- ;--- The first byte is the length (0-16) --------
- ;--- The following characters are the password --
- ;--- Only an exact match will allow the system --
- ;--- to continue the boot process ---------------
-
- 0012 08 50 61 73 73 57 password_store db 8,'PassWord'
- 6F 72 64
- 001B 09 [ db $-password_store dup(' ') ;leave room for a
- 20
- ]
-
- ;16 character password
-
- 0024 10 in_buf_max db 16 ;input buffer for reading password from user
- 0025 ?? in_buf_len db ? ;it is set up for DOS service OAH, BUFFERED_INPUT
- 0026 10 [ in_buf db 16 dup(?)
- ??
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-2
-
-
-
- ]
-
-
- ;----- The STRATEGY proc stores ES:BX request header pointer here
- ;----- The INTERRUPT proc retrieves it
-
- 0036 request_ptr label dword ;defined as double word for LES opcode
- 0036 ???? req_ptr_off dw ? ;and as two words for MOV opcodes
- 0038 ???? req_ptr_seq dw ?
-
-
-
- 003A dummy_iret: ;Ctrl-Break vector is pointed here, so it
- 003A CF IRET ;does nothing. Break is not recognized.
-
- ;------------------messages----------------------------------------------------
- ;These messages are expected to be output via the ANSI.SYS device,
- ;so it should be installed (named in the CONFIG.SYS file) before
- ;this PWORD device.
- ;If you don't want to use ANSI.SYS, remove the ESC sequences in the messages.
-
- = 000A lf equ 0ah
- = 000D cr equ 0dh
- = 001B esc equ 1bh
-
- 003B 0D 0A 1B 5B 30 6D msg_1 db cr,lf,esc,'[0m' ;make output visible
- 0041 45 6E 74 65 72 20 db 'Enter Password: '
- 50 61 73 73 77 6F
- 72 64 3A 20
- 0051 1B 5B 38 6D 24 db esc,'[8m$' ;make input invisible
-
- 0056 0D 0A 1B 30 6D msg_2 db cr,lf,esc,'0m' ;make output visible
- 005B 50 61 73 73 77 6F db 'Password accepted.',cr,lf,'$'
- 72 64 20 61 63 63
- 65 70 74 65 64 2E
- 0D 0A 24
-
- ;==============================================================================
- ;STRATEGY procedure
- ;Just saves the request header pointer for the INTERRUPT proc
-
- 0070 strategy proc far
- assume cs:dev_seg
- 0070 2E: 89 1E 0036 R mov cs:req_ptr_off,bx
- 0075 2E: 8C 06 0000 U mov cs:req_ptr_seg,es
- E r r o r --- 9:Symbol not defined
- 007A CB ret ;far return to DOS
- 007B strategy endp
-
- ;==============================================================================
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-3
-
-
-
- ;INTERRUPT procedure
- ;Processes the command indicated in the request header.
-
- 007B interrupt proc far
- assume cs:dev_seg,ds:nothing, es:nothing
- 007B 1E push ds ;preserve all registers
- 007C 06 push es
- 007D 50 push ax
- 007E 53 push bx
- 007F 51 push cx
- 0080 52 push dx
- 0081 57 push di
- 0082 56 push si
- 0083 8C C8 mov ax,cs ;make DS address the
- 0085 8E D8 mov ds,ax ;program data area
-
- 0087 2E: C4 1E 0036 R les bx,request_ptr ;get the pointer saved by STATEGY
- 008C 26: 8A 47 02 mov al,es:[bx+2] ;fetch the command
- 0090 3C 00 cmp al,0
- 0092 74 14 je init_fn ;only valid request in INIT_FN
- 0094 error_exit:
- 0094 26: 81 4F 03 8003 or word ptr es:[bx+3],8003H ;indicate error code 3:
- ;"Unknown command"
-
- ;---- interrupt service request has been handled.
- ;---- Set he "done flag" and return to DOS.
-
- 009A common_exit:
- 009A 26: 81 4F 03 0100 or word ptr es:[bx+3],100H ;set the done bit
- 00A0 5E pop si
- 00A1 5F pop di
- 00A2 5A pop dx
- 00A3 59 pop cx
- 00A4 5B pop bx
- 00A5 58 pop ax
- 00A6 07 pop es
- 00A7 1F pop ds
- 00A8 ret :far return
- E r r o r --- 10:Syntax error
-
- ;---- Only the INIT function is handled by the PWORD device
- ;---- all other requests are routed through the error_exit.
-
- ;----------------------------------
- ;INIT_FN procedure
- ;prompts the user for a password, keeps prompting until correct entry
- ;received, Passes the address of this proc back to DOS as the end-of-driver
- ;address so that a minimum amount of storage is used.
-
- 00A8 init_fn proc near
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-4
-
-
-
-
- 00A8 06 push es
-
- ;--------------
- ;The following 4 lines eliminate Ctrl-Break from having
- ;any effect on the system, unless another program
- ;KEYBOARD_BREAK vector is altered (BASIC does that).
-
- 00A9 B8 0000 mov ax,0
- 00AC 8E C0 mov es,ax
- 00AE 26: C7 06 006C 003A R mov word ptr es:[1Bh*4],offset dummy_iret
- 00B5 26: 8C 0E 006E mov word ptr es:[1Bh*4+2],cs
- 00BA EB 06 jmp short no_beep
- 00BC try_again:
- 00BC B0 07 mov al,7 ;bel character
- 00BE B4 0E mov ah,0EH ;WRITE_TTY service
- 00C0 CD 10 int 10h
- 00C2 no_beep:
- 00C2 BA 003B R mov dx,offset msg_1 ;"Enter Password:"
- 00C5 B4 09 mov ah,9 ;DOS print string service
- 00C7 CD 21 int 21H
-
- 00C9 BA 0024 R mov dx,offset in_buf_max
- 00CC B4 0C mov ah,0Ch ;clear input buffer and..
- 00CE B0 0A mov al,0Ah ;input a line of characters
- 00D0 CD 21 int 21H
- 00D2 8C C8 mov ax,cs
- 00D4 8E C0 mov es,ax ;set ES to target password for DMPSB
- ;DS already points to user input
- 00D6 BE 0000 U mov si,offset in_buf_store
- E r r o r --- 9:Symbol not defined
- 00D9 B5 00 mov ch,0
- 00DB 8A 0C mov cl,[si]
- 00DD 3A 0D cmp cl,[di] ;are lengths the same?
- 00DF 75 DB jne try_again
- 00E1 47 inc di ;point to first characters
- 00E2 46 inc si ;of both strings
- 00E3 F3/ A6 rep cmpsb ;all chars the same?
- 00E5 75 D5 jne try_again ;no, start over
-
- 00E7 BA 0056 R mov dx,offset msg_2 ;"Password accepted"
- 00EA B4 09 mov ah,9
- 00EC CD 21 int 21H
-
- ;---- now exit from INIT procedure -----------------------------
- ;---- retain only the minimum amount of code -------------------
- ;---- to handle erroneous service requests ---------------------
-
- 00EE 07 pop es
- 00EF 26: C7 87 0000 U 00A8 R mov word ptr es:[bx+OEH],offset init_fn ;end is at this proc
- E r r o r --- 9:Symbol not defined
- The Microsoft MACRO Assembler 11-17-83 PAGE 1-5
-
-
-
- 00F6 26: 8C 8F 0001 U mov word ptr es:[bx+1OH],cs ;segment is at current CS
- E r r o r --- 9:Symbol not defined
-
- 00FB EB 9D jmp common_exit
- 00FD init_fn endp
-
- 00FD interrupt endp
- 00FD pword_device endp
- 00FD dev_seg ends
- end pword_dev_header ;must specify end for EXE2BIN
-
- The Microsoft MACRO Assembler 11-17-83 PAGE Symbols-1
-
-
-
- Segments and groups:
-
- N a m e Size align combine class
-
- DEV_SEG. . . . . . . . . . . . . 00FD PARA NONE
-
- Symbols:
-
- N a m e Type Value Attr
-
- COMMON_EXIT. . . . . . . . . . . L NEAR 009A DEV_SEG
- CR . . . . . . . . . . . . . . . Number 000D
- DEVICE_NAME. . . . . . . . . . . L BYTE 000A DEV_SEG
- DEV_ATTRIBUTE. . . . . . . . . . L WORD 0004 DEV_SEG
- DUMMY_IRET . . . . . . . . . . . L NEAR 003A DEV_SEG
- ERROR_EXIT . . . . . . . . . . . L NEAR 0094 DEV_SEG
- ESC. . . . . . . . . . . . . . . Number 001B
- INIT_FN. . . . . . . . . . . . . N PROC 00A8 DEV_SEG Length =0055
- INTERRUPT. . . . . . . . . . . . F PROC 007B DEV_SEG Length =0082
- INTERRUPT_PTR. . . . . . . . . . L WORD 0008 DEV_SEG
- IN_BUF . . . . . . . . . . . . . L BYTE 0026 DEV_SEG Length =0010
- IN_BUF_LEN . . . . . . . . . . . L BYTE 0025 DEV_SEG
- IN_BUF_MAX . . . . . . . . . . . L BYTE 0024 DEV_SEG
- LF . . . . . . . . . . . . . . . Number 000A
- MSG_1. . . . . . . . . . . . . . L BYTE 003B DEV_SEG
- MSG_2. . . . . . . . . . . . . . L BYTE 0056 DEV_SEG
- NEXT_DEV_PTR . . . . . . . . . . L DWORD 0000 DEV_SEG
- NO_BEEP. . . . . . . . . . . . . L NEAR 00C2 DEV_SEG
- PASSWORD_STORE . . . . . . . . . L BYTE 0012 DEV_SEG
- PWORD_DEVICE . . . . . . . . . . F PROC 0000 DEV_SEG Length =00FD
- PWORD_DEV_HEADER . . . . . . . . L NEAR 0000 DEV_SEG
- REQUEST_PTR. . . . . . . . . . . L DWORD 0036 DEV_SEG
- REQ_PTR_OFF. . . . . . . . . . . L WORD 0036 DEV_SEG
- REQ_PTR_SEQ. . . . . . . . . . . L WORD 0038 DEV_SEG
- RET. . . . . . . . . . . . . . . L NEAR 00A8 DEV_SEG
- STRATEGY . . . . . . . . . . . . F PROC 0070 DEV_SEG Length =000B
- STRATEGY_PTR . . . . . . . . . . L WORD 0006 DEV_SEG
- TRY_AGAIN. . . . . . . . . . . . L NEAR 00BC DEV_SEG
-
- Warning Severe
- Errors Errors
- 0 5